import request from '@/utils/request'

// 查询文章列表
export function articleList(query) {
	return request({
		url: '/article/articleList',
		method: 'get',
		headers: {
			isToken: false
		},
		params: query
	})
}

// 搜索文章
export function search(keyword) {
	return request({
		url: '/article/search/' + keyword,
		method: 'get'
	})
}

//查询最热文章
export function hotArticleList() {
	return request({
		url: '/article/hotArticleList',
		headers: {
			isToken: false
		},
		method: 'get'
	})
}

//查询最新文章
export function newArticleList() {
	return request({
		url: '/article/newArticleList',
		headers: {
			isToken: false
		},
		method: 'get'
	})
}

//获取文章数据
export function articleData() {
	return request({
		url: '/article/numData',
		headers: {
			isToken: false
		},
		method: 'get'
	})
}

//获取文章详情
export function getArticle(articleId) {
	return request({
		url: '/article/' + articleId,
		method: 'get'
	})
}

//获取所有置顶文章
export function getTopList() {
	return request({
		url: '/article/topList',
		headers: {
			isToken: false
		},
		method: 'get'
	})
}

export function updateViewCount(articleId) {
	return request({
		url: '/article/updateViewCount/' + articleId,
		headers: {
			isToken: false
		},
		method: 'put'
	})
}

// 点赞
export function like(articleId) {
	return request({
		url: '/article/like/' + articleId,
		method: 'put',
		// params: {
		// 	"articleId": articleId
		// }
	})
}

// 取消点赞
export function cancelLike(articleId) {
	return request({
		url: '/article/cancelLike/' + articleId,
		method: 'put',
		// params: {
		// 	"articleId": articleId
		// }
	})
}

// 获取赞过的文章
export function getMyLikes() {
	return request({
		url: '/article/getMyLikes',
		method: 'get'
	})
}